package com.action;

import java.util.List;



import com.dao.LoginDao;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import com.proj.User;



public class LoginAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	//登录用户数据模块
	private User user;

	
	LoginDao logindao = new LoginDao();
	
	public String loginCheck() throws ClassNotFoundException{
		// 怎么访问数据库
		
		User result = logindao.dataCheck(user);
		if(result == null) {
			return INPUT;
		}
		else {
			ActionContext.getContext().put("info",result);
			return SUCCESS;
		}
	}
	//角色查询
	public String querCheck() throws ClassNotFoundException{
		
		LoginDao logindao = new LoginDao();
		List <User> list =  logindao.getAllUser();
		ActionContext context = ActionContext.getContext();
		context.put("list", list);
		return SUCCESS;
	}
	
	//角色维护
	public String mainCheck() throws ClassNotFoundException{
			
			LoginDao logindao = new LoginDao();
			List <User> list =  logindao.getAllUser();
			ActionContext context = ActionContext.getContext();
			context.put("list", list);
			return SUCCESS;
		}
	//用户新增模块
	/*public String addLogin(){
		LoginDao dao = logindao.addUserById(user);
		dao.addUserById(user);
		
		return SUCCESS;
		
		}*/
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
}
